<script type="text/javascript">

	tinyMCE.init({
	 	plugins : '-example', // - tells TinyMCE to skip the loading of the plugin
	    mode : "textareas",
	    theme : "advanced",
	    editor_selector : "rte",
	    theme_advanced_buttons1 : "mylistbox,mysplitbutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink",
	    theme_advanced_buttons2 : "",
	    theme_advanced_buttons3 : "",
	    theme_advanced_toolbar_location : "top",
	    theme_advanced_toolbar_align : "left",
	    theme_advanced_statusbar_location : "",

	    document_base_url : "{$ad}",
	    width: "420",
		height: "auto",
		entity_encoding: "raw",
		convert_urls : false,
		language : "{$iso}"
	});

</script>
{include file="$tpl_dir./breadcrumb.tpl"}
				
<h2>{l s="View Detail Ticket page"}</h2>
{include file="$tpl_dir./errors.tpl"}
{if $id_customer}

{if isset($complete) && $complete}
	<div class="confimComplete">
		<img src="{$img_ps_dir}admin/ok2.png" alt="zhelpdesk" title="" />
		{l s="Message's you had post."}
	</div>
{/if}

<div id="reply-ticket">
	<form class="std" id="reply-ticket_form" method="post" enctype="multipart/form-data" action="">
		<fieldset class="tiket-info">
			<h3>{l s="Ticket Info"}</h3>
			<p class="name-ticket">
				<b>{l s="Ticket Code:"}</b> {$ticket.ticket_code}
			</p>
			<p class="status">
				<b>{l s="Status:"}</b> <span style="background-color:{$ticket.status_background};color:{$ticket.status_color}"> {$ticket.status} </span>
			</p>
			<p class="priority">
				<b>{l s="Priotiry:"}</b> <span style="background-color:{$ticket.priority_background};color:{$ticket.priority_color}">{$ticket.priority}</span>
			</p>
			<p class="department">
				<b>{l s="Department:"}</b> {$ticket.department|truncate:200}
			</p>
			<p class="subject">
				<b>{l s="Subject:"}</b> {$ticket.subject|truncate:200}
			</p>
			<p class="order">
				<b>{l s="Order:"}</b>
				{if $ticket.id_order==0}No order {else}<a class="color-myaccount" style="color: #DD2A81;" href="{$link->getPageLink('history.php')}">#{$ticket.id_order|string_format:"%06d"}</a>{/if}
			</p>
			<p class="moderator" {if $ticket.id_order==0}style="margin-left: 26%;"{/if}>
				<b>{l s="Moderator:"}</b> {$ticket.firstname_employee} {$ticket.lastname_employee}  
			</p>
		</fieldset>
		<fieldset class="reply-support">
			<h3>{l s="Post a reply"}</h3>
			<p class="textarea required">
				<label for="content" style="">{l s="Message"}<sup>*</sup></label>
				<textarea class="" cols="48" rows="8" name="content" id="content">{if isset($complete) && $complete}{else}{if isset($smarty.post.content)}{$smarty.post.content}{/if}{/if}</textarea>
			</p>
			<p class="attached_files" style="padding-top: 17px;">
				<label for="content" style="content-post-ticket">{l s="File Attachment"}<sup></sup></label>
				<input type="file" value="" name="attached_files" />
			</p>
		</fieldset>
		<p class="cart_navigation required submit reply-ticket">
			<input type="submit" name="submitReplyTicket" id="submitReplyTicket" value="{l s='Reply'}" class="exclusive" />
			<span><sup>*</sup>{l s='Required field'}</span>
		</p>
		
		<fieldset class="ticket-thread">
			<h3>{l s="Ticket Thread"}</h3>
			{if sizeof($messages)>0}
				{foreach from=$messages item=message}
					<table cellspacing="0" cellpadding="0" style="width:100%;border: 1px solid #8D8E8E;" class="table" id="tableThread">
						<thead>
							<tr class="nodrag nodrop">
								<th style="background:none;background-color:#A5B6BA;" colspan="2"><span class="name">{if $message.id_staff==0}{$message.name_customer}{else}{$message.firstname_employee} {$message.lastname_employee}{/if} </span> <span class="date_add">{$message.date_add|date_format:"%I:%M %p, %A, %B %e, %Y"}</span></th>
							</tr>
						</thead>
					<tbody>
						<tr>
							<td style="font-size: 1.1em;" colspan="2">{$message.content}</td>
						</tr>
						<tr>
							<td style="width: 65%;">
								{if $id_customer!=$message.id_customer || $message.id_staff!=0}
									{l s="Rating:"} <select id="helpdesk-ticket-rating_{$message.id_zhelpdesk_ticket_content}" name="" onchange="updateRating({$id_ticket},{$message.id_zhelpdesk_ticket_content},{$id_customer})">
				        				<option value="" >{l s="Choose"}</option>
				        				{foreach from=$ratings item=rating}
				        					<option {if $rating.id_zhelpdesk_ticket_rating == $message.id_zhelpdesk_ticket_rating}selected="selected"{/if}value="{$rating.id_zhelpdesk_ticket_rating}">{$rating.rating}</option>
				        				{/foreach}
				        			</select>
				        		{else}
				        			{if $message.id_zhelpdesk_ticket_rating!=0}
				        				{l s="Rating:"} 
					        			{foreach from=$ratings item=rating}
					        				{if $rating.id_zhelpdesk_ticket_rating == $message.id_zhelpdesk_ticket_rating}
					        					{$rating.rating}
					        				{/if}
					        			{/foreach}
				        			{else}
				        				{l s="No rated"}
				        			{/if}
				        		{/if}
							</td>
							<td>
								{if $message.attached_files!=''}
									<a href="{$message.link_attached_files}" target="_blank"><img src="{$_MODULE_DIR_}/zhelpdesk/img/AdminAttachments.gif"> {$message.attached_files}</a>
								{/if}
							</td>
						</tr>
						
					</tbody>
				</table>
				{/foreach}
		    {else}
		    <p style="text-align: center;">{l s="Not found message"}</p>
		    {/if}
		</fieldset>
	</form>
</div>
{include file="$tpl_dir./pagination.tpl"}
{/if}
